package com.ihisun.tmhcms.core.dao.mechanismdao;

import com.ihisun.tmhcms.core.vo.MechanismVo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MechanismDao extends JpaRepository<MechanismVo, Long> {
    public List<MechanismVo> findByMechanismId(String mechanismId);

    @Query(value = "select * from m_mechanism mm INNER JOIN m_mechanism_d_doctor mmdd on mmdd.mechanism_id=mm.mechanism_id and mmdd.doctor_id=:doctorId", nativeQuery = true)
    public List<MechanismVo> findByDoctorMechanism(@Param("doctorId") String doctorId);

    public List<MechanismVo> findByState(Integer state);

    public List<MechanismVo> findByMechanismClassification(String typeId);

    public Integer countByMechanismClassificationAndStateNot(String typeId, Integer state);

    @Query(value = "select * from m_mechanism where state=1", nativeQuery = true)
    public List<MechanismVo> findByAll();

    public List<MechanismVo>findByCity(String city);

    public List<MechanismVo>findByHousekeeperId(String keeperId);
}
